package Day13_StringBuilder类;

//定义一个方法,输入abcd1234 打印4321dcba

//后续学习,可以用StringBuilder类的反转方法 sb.reverse,再将StringBuilder转换成String.  (demo02)

import java.util.Scanner;

public class String_字符串反转 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("输入一个字符串:");
        String s = sc.next();
        xxx(s);
        System.out.print(xxx(s));
    }

    public static String xxx(String s) {
        String s1 = "";
        //反向遍历字符串
        for (int i = s.length() - 1; i >= 0; i--) {
            s.charAt(i);

            s1 += s.charAt(i);
        }
        return s1;
    }
}
